package ar.edu.itba.tp1.tpalan;

import ar.edu.itba.tp1.gps.CalcuDokuEngine;
import ar.edu.itba.tp1.gps.GPSEngine;
import ar.edu.itba.tp1.gps.SearchStrategy;
import ar.edu.itba.tp1.gps.api.GPSProblem;


public class Main {
	public static void main(String[] args) {
		if (args.length < 1 || args.length > 2) {
			System.out.println("\nUsage: \nstrategy [heuristic]\n\n" +
					"strategy = DFS, BFS, IDS, AStar, Greedy\n" +
					"You can choose one of this parameters of the heuristics combination\n" +
					"1 = ColorCount\n" +
					"2 = Distance remaining to bottom right corner\n" +
					"3 = combination of both\n");
			return;
		}

		SearchStrategy strategy = null;
		if (args[0].equalsIgnoreCase("DFS")) strategy = SearchStrategy.DFS;
		else if (args[0].equalsIgnoreCase("BFS")) strategy = SearchStrategy.BFS;
		else if (args[0].equalsIgnoreCase("IDS")) strategy = SearchStrategy.PI;
		else if (args[0].equalsIgnoreCase("AStar")) strategy = SearchStrategy.AStar;
		else if (args[0].equalsIgnoreCase("Greedy")) strategy = SearchStrategy.GS;
		else { 
			System.err.println(args[0] + " not a valid strategy");
			return;
		}

		Heuristic heuristic = Heuristic.None;
		if (args.length == 2) {
			if (args[1].equalsIgnoreCase("1")) heuristic = Heuristic.ColorCount;
			else if (args[1].equalsIgnoreCase("2")) heuristic = Heuristic.FarCluster;
			else if (args[1].equalsIgnoreCase("3")) heuristic = Heuristic.Both;
			else if (args[1].equalsIgnoreCase("4")) heuristic = Heuristic.RemainingSquares;
			else { 
				System.err.println(args[1] + " not a valid heuristic");
				return;
			}
		}
		
		GPSEngine engine = new CalcuDokuEngine();
		GPSProblem problem = new MyGPSProblem(heuristic);
		engine.engine(problem, strategy);
	}
}
